<?php

namespace Interno\UserBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UserType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
        	->add('username')
        	->add('email')
        	->add('enabled')
        	->add('plainPassword', 'repeated', array(
        			'type' => 'password',
        			'options' => array('translation_domain' => 'FOSUserBundle'),
        			'first_options' => array('label' => 'form.password'),
        			'second_options' => array('label' => 'form.password_confirmation'),
        			'invalid_message' => 'fos_user.password.mismatch',
        	))
            ->add('groups')
            ->add('container')
        ;
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Interno\UserBundle\Entity\User'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'interno_userbundle_user';
    }
}
